import React, { Component } from 'react'
import {Button} from "antd"
import {throttle} from "lodash" // 从loash引入节流
var timmer = null;
 class F401 extends Component {
  state = {
      timer:3
  }
  componentDidMount(){
       timmer =  setInterval(()=>{
          console.log(1111);
          this.setState({
              timmer:this.state.timer --
          })
      },1000)
      setTimeout(()=>{
        this.props.history.push({
            pathname:"/login"
        })
      },3000)
  }
  goLogin(){
      this.props.history.push({
          pathname:"/login"
      })
  }
  componentWillUnmount(){
    clearInterval(timmer) // 合理释放内存
  }
  render() {
    return (
      <div>
          <h1>您没有登陆，没有导航得冯文权限，请您登陆</h1>
          <h1>{this.state.timmer}后跳转页面</h1>
          <Button onClick={ throttle(this.goLogin.bind(this),1500,{leading:false,trailing:true})}>点击我去登陆页面</Button>
      </div>
    )
  }
}

export default F401